

package com.hazelcast.internal.dynamicconfig.search;

import com.hazelcast.config.Config;
import com.hazelcast.internal.dynamicconfig.ConfigurationService;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;

/**
 * Config supplier, which helps to match type of the config to corresponding search method.
 *
 * @param <T> specifies type of the config
 * @see ConfigSearch
 * @since 3.11
 */
public interface ConfigSupplier<T extends IdentifiedDataSerializable> {
    /**
     * Get dynamic configuration for the given name
     *
     * @param configurationService configuration service
     * @param name                 data structure name
     * @return configuration if found, or <code>null</code>
     */
    @Nullable
    T getDynamicConfig(@Nonnull ConfigurationService configurationService, @Nonnull String name);

    /**
     * Get static configuration for the given name
     *
     * @param staticConfig static config
     * @param name         data structure name
     * @return configuration if found, or <code>null</code>
     */
    @Nullable
    T getStaticConfig(@Nonnull Config staticConfig, @Nonnull String name);

    /**
     * Get all static configs for the given config type.
     *
     * @param staticConfig static config
     * @return name-to-config map
     */
    Map<String, T> getStaticConfigs(@Nonnull Config staticConfig);
}
